package cn.anlaser.exception;

/**
 * @author jskyme
 * 
 */
public class NutException extends RuntimeException {
	private Exception currExce = null;
	private static final long serialVersionUID = 1L;
	private String code;

	/**
	 * @param exception
	 */
	public NutException(Exception exception) {
		currExce = exception;
	}

	public NutException(String code, String message) {
		super(message);
		this.code = code;
		currExce = new RuntimeException(message);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Throwable#printStackTrace()
	 */
	public void printStackTrace() {
		currExce.printStackTrace();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Throwable#getMessage()
	 */
	public String getMessage() {
		return currExce.getMessage();
	}

	/**
	 * @return
	 */
	public Exception getCurrExce() {
		return currExce;
	}

	/**
	 * @param currExce
	 */
	public void setCurrExce(Exception currExce) {
		this.currExce = currExce;
	}

	/**
	 * 
	 */
	public String exception() {
		StringBuffer exception = new StringBuffer();
		System.out.println(currExce);
		StackTraceElement[] trace = currExce.getStackTrace();
		for (int i = 0; i < trace.length; i++) {
			exception.append("\tat " + trace[i]);
		}
		return exception.toString();
	}

	public String isCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

}
